package com.syt.service.service;

import com.syt.service.dao.PhoneUserMapper;
import com.syt.service.pojo.PhoneUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author ：syt
 * @date ：Created in 2019-10-06 20:38
 * @description：用户 服务
 */
@Service
public class PhoneUserService {

    @Autowired(required = false)
    PhoneUserMapper userMapper;

    /**
     * 查询 用户的方法 根据id
     * @param userId
     * @return
     */
    public PhoneUser findUserById(String userId) {
        return userMapper.selectByPrimaryKey(Integer.valueOf(userId));
    }

    /**
     * 更新用户
     * @param user
     * @return
     */
    public Integer updateUser(PhoneUser user) {
        return userMapper.updateByPrimaryKeySelective(user);
    }

    /**
     * 插入用户到数据库
     * @param user
     * @return
     */
    public Integer setUser(PhoneUser user) {
        return userMapper.insertSelective(user);
    }

    /**
     * 删除用户
     * @param userId
     * @return
     */
    public Integer deleteUser(String userId) {
        return userMapper.deleteByPrimaryKey(Integer.parseInt(userId));
    }

    /**
     * 根据名称  查询用户
     * @param userName
     * @return
     */
    public PhoneUser findUserByName(String userName) {
        return userMapper.selectByUserName(userName);
    }
}
